@extends('admin.layout')
@section('content')
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="col-md-12" id="content">
            <div class="app_content_div" id="app_content_div_301Index">
                <h3>管理员用户列表</h3>
            </div>
            <div>
                <div style="float:right;">
                    <a href="/adm/user/add-user"><button type="button" class="btn btn-primary">新增管理员</button></a>
                </div>
            </div>
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>id</th>
                    <th>用户名</th>
                    <th>更改密码</th>
                    <th>删除</th>
                </tr>
                </thead>
                @foreach($oUser as $v)
                    <tbody>
                    <tr>
                        <th scope="row">{{$v->id}}</th>
                        <td>{{$v->name}}</td>
                        <td><a style="cursor:pointer;" href="/adm/user/edit-user/{{$v->id}}">更改密码</a></td>
                        <td>
                            <a onclick="del({{$v->id}},'{{$v->name}}');"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                        </td>

                    </tr>
                    </tbody>
                @endforeach
            </table>
        </div>
    </div>
    <script>
        function del(id,name){
            var conf = confirm('你确定要删除'+name+'吗？');
            if(conf=true){
                $.ajax({
                    url:'/adm/user/'+id,
                    type:'DELETE',
                    dataType:'json',
                    data:{'_token':'{{csrf_token()}}'},
                    success:function (data){
                        alert('删除成功');
                        location.href='/adm/user';
                    },
                    error:function (data){}
                });
            }}
    </script>
@endsection
